package model

import (
	"time"
)

type Customer struct {
	CustomerId int `xorm:"pk autoincr"`
	CustomerName string
	CustomerType int
	FounderId int
	FounderName string
	BelongerId int
	BelongerName string
	AllocationTime time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
 }

func (ct *Customer)InsertCustomer(c *Customer) map[string]string{
	x.Insert(c)
	return map[string]string{"message": "成功","code":"200"}
}

func (ct *Customer)QueryCustomerById(cId int) *Customer{
	var c *Customer
	x.Id(cId).Get(c)
	return c
}

func (ct *Customer)QueryCustomerByBloo(cId int) bool{
	var c *Customer
	x.Id(cId).Get(c)
	if c != nil && time.Now().Sub(c.AllocationTime).Hours()/24 <= 90{
		return true
	}
	return false
}